package gspushmq.v1.app.subscribeapp.enumeration;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Description 不接受推送人群枚举类
 * @Author chengsj
 * @Date 2018/9/20 14:13
 * @Version 1.0
 * @company 上海朝阳永续信息技术有限公司
 * @copyright (c) 2015 SunTime Co'Ltd Inc. All rights reserved.
 *
*/
import org.apache.commons.lang3.StringUtils;

/**
 *
 * @Description 用户权限枚举
 *
 * @Author chengsj
 * @Version 1.0
 *
 */
public enum TagNoPushEnum {



	NO_ASSISTANT(-1001,"不接受智投小秘书消息","NO_ASSISTANT"),
	NO_OWNCHOOSECHANGE(-1002,"不接受自选股动态消息","NO_OWNCHOOSECHANGE"),
	NO_LIVEREMINDER(-1003,"不接受直播提醒消息","NO_LIVEREMINDER");


	//消息类型
	private int code;
	//消息名称
	private String name;

	private String tag;

	TagNoPushEnum(int code, String name, String tag) {
		this.code = code;
		this.name = name;
		this.tag = tag;
	}

	public int getCode() {
		return code;
	}

	public void setCode(int code) {
		this.code = code;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}


	public String getTag() {
		return tag;
	}

	public void setTag(String tag) {
		this.tag = tag;
	}

	/**
	 *
	 * @Description
	 * @Author chengsj
	 * @Version 1.0
	 *
	 */
	public static TagNoPushEnum getEnumByCode(Integer code){
		if (code == null)
			return null;

		for (TagNoPushEnum p : TagNoPushEnum.values())
			if (p.getCode() == code)
				return p;

		return null;
	}

	public static String getTagByCode(Integer code){
		if (code == null)
			return null;

		for (TagNoPushEnum p : TagNoPushEnum.values())
			if (p.getCode() == code)
				return p.getTag();

		return null;
	}

	/**
	 *
	 * @Description 根据name获取相关key
	 * @Author chengsj
	 * @Version 1.0
	 *
	 */
	public static Integer getCodeByName(String name){
		if (StringUtils.isBlank(name))
			return null;

		for (TagNoPushEnum pe : TagNoPushEnum.values())
			if (pe.getName().equals(name))
				return pe.getCode();

		return null;
	}
	public static String getByNameCode(Integer code){
		if (code == null)
			return null;

		for (TagNoPushEnum pe : TagNoPushEnum.values())
			if (pe.getCode() == code)
				return pe.getName();

		return null;
	}
	/**
     * 
     * 方法描述 获取枚举值对应的key-value集合
     *
     * @return
     * 
     * @author yaomy
     * @date 2018年5月16日 下午7:04:26
     */
    public static List<Map<String, Object>> toMap(){
    	List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
    	for(TagNoPushEnum type : TagNoPushEnum.values()) {
    		Map<String, Object> map = new HashMap<String, Object>();
    		map.put("code", type.code);
    		map.put("name", type.name);
    		list.add(map);
    	}
    	return list;
    }
}
